import Cookies from 'js-cookie'

const TokenKey = 'Heima-Slwl-token'
const UserInfor = 'user_infor'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function setUserInfor(value) {
  // return localStorage.setItem(UserInfor, JSON.stringify(value))
  return Cookies.set(UserInfor, value)
}

export function getUserInfor() {
  // return JSON.parse(localStorage.getItem(UserInfor))
  return Cookies.get(UserInfor)
}

export function removeUserInfor() {
  // return localStorage.removeItem(UserInfor)
  return Cookies.remove(UserInfor)
}

export function jsonParse(data) { // 将数据反序列化的方法
  return JSON.parse(data)
}
